package com.study.designpattern.builder;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class BuilderTest {
    public static void main(String[] args) {
        Product productLow = new ProductDirector().createProductByDirector(new LowProductBuilder());
        System.out.println(productLow);
        Product productMid = new ProductDirector().createProductByDirector(new MidProductBuilder());
        System.out.println(productMid);
    }
}
@AllArgsConstructor
@NoArgsConstructor
@Data
class Product{
    private String productName;
    private String companyName;
    private String part1;
    private String part2;
    private String part3;
    private String part4;
}
interface ProductBuilder{
     void buildProductName();
     void buildCompanyName();
     void buildPart1();
     void buildPart2();
     void buildPart3();
     void buildPart4();
     Product buildProduct();
}
class LowProductBuilder implements ProductBuilder{
    Product product;
    LowProductBuilder(){
        product=new Product();
    }
    @Override
    public void buildProductName() {
        product.setProductName("lowProduct");
    }

    @Override
    public void buildCompanyName() {
        product.setCompanyName("lowCompany");
    }

    @Override
    public void buildPart1() {
        product.setPart1("low_part1");
    }

    @Override
    public void buildPart2() {
        product.setPart1("low_part2");
    }

    @Override
    public void buildPart3() {
        product.setPart1("low_part3");
    }

    @Override
    public void buildPart4() {
        product.setPart1("low_part4");
    }
    public  Product buildProduct(){
        return product;
    }
}
class MidProductBuilder implements ProductBuilder{
    Product product;
    MidProductBuilder(){
        product=new Product();
    }
    @Override
    public void buildProductName() {
        product.setProductName("midProduct");
    }

    @Override
    public void buildCompanyName() {
        product.setCompanyName("midCompany");
    }

    @Override
    public void buildPart1() {
        product.setPart1("mid_part1");
    }

    @Override
    public void buildPart2() {
        product.setPart1("mid_part2");
    }

    @Override
    public void buildPart3() {
        product.setPart1("mid_part3");
    }

    @Override
    public void buildPart4() {
        product.setPart1("mid_part4");
    }
    public  Product buildProduct(){
        return product;
    }
}
class ProductDirector{
    public Product createProductByDirector(ProductBuilder builder){
        builder.buildProductName();
        builder.buildCompanyName();
        builder.buildPart1();
        builder.buildPart2();
        builder.buildPart3();
        builder.buildPart4();
        return builder.buildProduct();
    }
}